/**
 * PreCreateResources
 * @ 文本动画
 */
// 动画帧

class TextAnimation {
    constructor() {
        this.animations = {
            guide: [{
                delay: 0,
                duration: 1,
                from: { y: window.innerHeight * 0.5 },
                to: { yoyo: true, repeat: -1, ease: 'easeOut', y: window.innerHeight * 0.48 }
            }, {
                delay: 0,
                duration: 0.1,
                to: { alpha: 0 }
            }],
            ad: [{
                delay: 0,
                duration: 0.1,
                to: { alpha: 0 }
            }],
            ad2: [{
                delay: 0,
                duration: 0.1,
                to: { alpha: 0 }
            }],
            ad3: [{
                delay: 0.9,
                duration: 0.1,
                from: { alpha: 0, y: window.innerHeight * 0.53 }
            }],
            ad4: [{
                delay: 0.9,
                duration: 0.1,
                from: { alpha: 0, y: window.innerHeight * 0.57 }
            }]
        }
        for (let i = 1; i < 8; i += 1) {
            const delay = 0.25 + (i / 7 * 0.2)
            const x = i % 2 === 0 ? window.innerWidth * 0.65 : window.innerWidth * 0.35
            this.animations[`item${i}`] = [{
                delay,
                duration: 0.2,
                to: { x, y: -window.innerHeight * 0.2, width: 0, height: 0 }
            }, {
                duration: 0.5 + Math.random(),
                to: { yoyo: true, repeat: -1, rotation: 0.1 }
            }]
        }
        return this.animations
    }
    getFrames(key, n, start = 0) {
        const frames = []
        for (let i = start; i < n + start; i += 1) {
            frames.push(`${key}${i}`)
        }
        return frames
    }
}

export default new TextAnimation()